package cn.wolfcode.rbac.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class CustomerTraceHistory {
    public static final int TYPE_COMMON=0;//潜在用户
    public static final int TYPE_NORMAL=1;//正式用户
    public static final int RESULT_BAD=1;//差结果
    public static final int RESULT_NORMAL=2;//中结果
    public static final int RESULT_GOOD=3;//优救国
    //记录编号
    private Long id;
    //跟进时间
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private Date traceTime;
    //跟进内容
    private String traceDetails;
    //跟进方式
    private SystemDictionaryItem traceType;
    //跟进结果
    private Integer traceResult=3;
    //备注
    private String remark;
    //客户
    private Customer customer;
    //录入人
    private Employee inputUser;
    //录入时间
    private Date inputTime;
    //跟进类型
    private Integer type=0;
    public String getResultName(){
        switch (traceResult){
            case RESULT_BAD:return "差";
            case RESULT_NORMAL:return "中";
        }
        return "优";
    }
    public String getTypeName(){
        switch (type){
            case TYPE_NORMAL:return "正式用户";
        }
        return "潜在用户";
    }
    public String getJson(){
        Map<String,Object> map=new HashMap<>();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = simpleDateFormat.format(traceTime);
        map.put("id",id);
        map.put("traceTime",format);
        map.put("traceDetails",traceDetails);
        map.put("traceType",traceType.getId());
        map.put("traceResult",traceResult);
        map.put("remark",remark);
        map.put("customer",customer.getName());
        map.put("type",type);
        return JSON.toJSONString(map);
    }
}